<template>
	<view class="text-box">
		<view class="header">
      <text class="cancel-text" @click="cancel">取消</text>
      <text class="text">{{modelTitle}}</text>
      <text class="ok-text" @click="save">确定</text>
    </view>
    <view class="text-input-box">
      <uv-textarea  class="input" count placeholder="请输入内容" :height="140" v-model="realVal" border="none" clearable></uv-textarea >
    </view>
	</view>
</template>

<script setup>
import {onLoad} from '@dcloudio/uni-app';
import {ref} from 'vue'
import {getUrlParams} from "@/utils/uniUtil.js";
import { useTextInputStore } from '@/stores/textInput.js'
const textInputStore = useTextInputStore()


const modelTitle = ref('')
const realVal = ref('')
const key = ref('')

onLoad((param) => {
  console.log(param)
  const params = getUrlParams();
  console.log('接收到的参数:', params);
  modelTitle.value = param.title
  realVal.value = param.val
  key.value = param.key
});

const cancel = () => {
  uni.navigateBack()
}

const save = () => {
  // 保存数据到 store
  textInputStore.setInputValue(key.value,realVal.value.trim())
  uni.navigateBack()
}

</script>
<style lang="scss">
page {
  background-color: #f3f7fa !important;
  min-height: 100vh !important;
  overflow: hidden !important;
}
</style>
<style scoped lang="scss">
.text-box{
  margin: 0 23.45rpx;
  .header{
    display: flex;
    justify-content: space-between;
    padding: 30rpx 0;
    .cancel-text{
      color: #666;
      font-size: 30rpx;
      font-weight: 500;
    }
    .text{
      color: #444;
      font-size: 34rpx;
      font-weight: 500;
    }
    .ok-text{
      color: #666;
      font-size: 30rpx;
      font-weight: 500;
    }
  }
  .text-input-box{
    margin: 40rpx 0;
    background-color: #fff;
    border-radius: 10px;
    .input{
      flex: 1;
      padding: 10rpx 20rpx;
      width: 100%;
      height: 100%;
      box-sizing: border-box;
      color: #333;
    }
  }
}
</style>
